package router

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/controller/artificial"
	"parking-lot-go-admin/controller/b2b"
	"parking-lot-go-admin/controller/b2c"
	"parking-lot-go-admin/controller/dingtalk/banner"
	"parking-lot-go-admin/controller/dingtalk/member"
	"parking-lot-go-admin/controller/dingtalk/news"
	"parking-lot-go-admin/controller/log"
	"parking-lot-go-admin/controller/parking_record"
	"parking-lot-go-admin/controller/parking_record/static_park"
	"parking-lot-go-admin/controller/parking_record/statistics"
	"parking-lot-go-admin/controller/reconciliation"
	"parking-lot-go-admin/controller/system/menu"
	"parking-lot-go-admin/controller/system/role"
	"parking-lot-go-admin/controller/white_list"
	"parking-lot-go-admin/controller/work"
	"parking-lot-go-admin/middleware"

	"github.com/gin-gonic/gin"

	dingtalkOrder "parking-lot-go-admin/controller/parking_record/dingtalk/order"
	parknflyOrder "parking-lot-go-admin/controller/parking_record/parknfly/order"
	xiaoqiangOrder "parking-lot-go-admin/controller/parking_record/xiaoqiang/order"
	currencyStatistics "parking-lot-go-admin/controller/statistics"
	timeoutNotLeaving "parking-lot-go-admin/controller/timeout_not_leaving"
	waitAppearOrder "parking-lot-go-admin/controller/wait_appear_order"
)

func StartRoutes(r *gin.Engine) {

	api := r.Group("/api")
	api.Use(middleware.AuthMiddleware())

	//下载文件
	api.GET("down", controller.Down)

	api.GET("routers", controller.Routers)

	//人工操作
	artificialRouter := api.Group("/artificial")
	{
		entryRouter := artificialRouter.Group("/entry")
		{
			entryRouter.POST("", artificial.EntryList)
			entryRouter.POST("/add", artificial.EntryAdd)
		}

		outRouter := artificialRouter.Group("/out")
		{
			outRouter.POST("", artificial.OutList)
			outRouter.POST("/add", artificial.OutAdd)
		}
	}

	//B2B
	b2bRouter := api.Group("/b2b_config")
	{
		b2bRouter.POST("/static", b2b.StaticConfig)
		b2bRouter.POST("/static/update", b2b.StaticConfigUpdate)
	}

	//B2C
	b2cRouter := api.Group("/b2c_config")
	{
		//小强停车
		b2cRouter.POST("/xiaoqiang", b2c.XiaoQiangConfig)
		b2cRouter.POST("/xiaoqiang/update", b2c.XiaoQiangConfigUpdate)

		//泊安飞
		b2cRouter.POST("/parknfly", b2c.ParknflyConfig)
		b2cRouter.POST("/parknfly/update", b2c.ParknflyConfigUpdate)
	}

	//日志
	logrouter := api.Group("/log")
	{
		//静态停车
		staticParkGroup := logrouter.Group("static_park")
		{
			//入参
			staticParkGroup.POST("/receive", log.StaticParkReceive)

			//in_out
			staticParkGroup.POST("/push", log.StaticParkPush)
		}

		//小强停车
		xiaoQiangGroup := logrouter.Group("xiaoqiang")
		{
			//入参
			xiaoQiangGroup.POST("/receive", log.XiaoQiangReceive)

			//进/出场
			xiaoQiangGroup.POST("/push", log.XiaoQiangPush)

			//扣费
			xiaoQiangGroup.POST("/deduct_money", log.XiaoQiangDeductMoney)
		}

		//泊安飞
		parknflyGroup := logrouter.Group("parknfly")
		{
			//入参
			parknflyGroup.POST("/receive", log.ParknflyReceive)

			//进/出场
			parknflyGroup.POST("/push", log.ParknflyPush)

			//扣费
			parknflyGroup.POST("/deduct_money", log.ParknflyDeductMoney)
		}

		//日志展示
		logrouter.POST("show", log.Show)
	}

	staticParkRouter := api.Group("/parking_record")
	{
		//静态停车
		staticParkGroup := staticParkRouter.Group("static_park")
		{
			//进场
			staticParkGroup.POST("/entry", static_park.Entry)
			// 扣费
			staticParkGroup.POST("/deduct_money", static_park.DeductMoney)
			//出场
			staticParkGroup.POST("/out", static_park.Out)
		}

		//统计数据
		statisticsGroup := staticParkRouter.Group("statistics")
		{
			statisticsGroup.POST("/entry", statistics.Entry)
			statisticsGroup.POST("/out", statistics.Out)
		}

		//小强停车
		xiaoQiangGroup := staticParkRouter.Group("xiaoqiang")
		{
			//订单统计
			xiaoQiangOrderGroup := xiaoQiangGroup.Group("order")
			{
				//订单列表
				xiaoQiangOrderGroup.POST("/list", xiaoqiangOrder.List)
				//补缴记录
				xiaoQiangOrderGroup.POST("/payment", xiaoqiangOrder.Payment)
			}
		}

		//泊安飞
		parknflyGroup := staticParkRouter.Group("parknfly")
		{
			//订单统计
			parknflyOrderGroup := parknflyGroup.Group("order")
			{
				//订单列表
				parknflyOrderGroup.POST("/list", parknflyOrder.List)
			}
		}

		//钉钉
		dingtalkGroup := staticParkRouter.Group("dingtalk")
		{
			//订单统计
			dingtalkOrderGroup := dingtalkGroup.Group("order")
			{
				//订单列表
				dingtalkOrderGroup.POST("/list", dingtalkOrder.List)
			}
		}

		staticParkRouter.POST("download", parking_record.Download)
	}

	//对账
	reconciliationRouter := api.Group("/reconciliation")
	{
		reconciliationRouter.POST("/list", reconciliation.List)
		reconciliationRouter.POST("/import", reconciliation.Import)
		reconciliationRouter.GET("/import_handle", reconciliation.ImportHandle)
	}

	//通用操作
	statisticsRouter := api.Group("/statistics")
	{
		//方格
		statisticsRouter.POST("grid", currencyStatistics.Grid)

		//折线图
		statisticsRouter.POST("line", currencyStatistics.Line)

		//问题反馈
		statisticsRouter.POST("question", currencyStatistics.Question)

	}

	systemRouter := api.Group("/system")
	{

		//权限
		roleGroup := systemRouter.Group("/role")
		{
			roleGroup.GET("/all", role.RoleAll)
			roleGroup.POST("/my", role.RoleMy)
			roleGroup.POST("/update_user", role.UpdateUserRole)

			roleGroup.POST("", role.List)
			roleGroup.POST("/update", role.UpdateRole)
			roleGroup.POST("/add", role.InsertRole)
			roleGroup.POST("/update_status", role.UpdateStatus)
			roleGroup.POST("/delete", role.Delete)
			roleGroup.POST("/update_group", role.UpdateGroup)
		}

		//分组
		menuGroup := systemRouter.Group("/menu")
		{
			menuGroup.GET("/all", menu.MenuAll)
			menuGroup.POST("/my", menu.MenuMy)

			menuGroup.POST("", menu.List)
			menuGroup.POST("/add", menu.InsertMenu)
			menuGroup.POST("/update", menu.UpdateMenu)
			menuGroup.POST("/delete", menu.DeleteMenu)
		}
	}

	//白名单
	whiteListRouter := api.Group("/white_list")
	{
		whiteListRouter.POST("/list", white_list.List)
		whiteListRouter.POST("/add", white_list.Insert)
		whiteListRouter.POST("/delete", white_list.Delete)
		whiteListRouter.POST("/download", white_list.Download)
	}

	//工作记录
	workOrderRouter := api.Group("/work_order")
	{
		workOrderRouter.POST("/list", work.List)
		workOrderRouter.POST("/add", work.Insert)
		workOrderRouter.POST("/update", work.Update)
		workOrderRouter.POST("/reply", work.Reply)
	}

	//钉钉
	dingtalkRouter := api.Group("/dingtalk")
	{
		//banner
		dingtalkBannerRouter := dingtalkRouter.Group("/banner")
		{
			dingtalkBannerRouter.POST("", banner.BannerList)
			dingtalkBannerRouter.POST("/add", banner.InsertBanner)
			dingtalkBannerRouter.POST("/update", banner.UpdateBanner)
			dingtalkBannerRouter.POST("/delete", banner.DeleteBanner)
		}

		//新闻
		dingtalkNewsRouter := dingtalkRouter.Group("/news")
		{
			dingtalkNewsRouter.POST("", news.NewsList)
			dingtalkNewsRouter.POST("/add", news.InsertNews)
			dingtalkNewsRouter.POST("/update", news.UpdateNews)
			dingtalkNewsRouter.POST("/delete", news.DeleteNews)
		}

		//会员
		dingtalkMemberRouter := dingtalkRouter.Group("/member")
		{
			dingtalkMemberRouter.POST("", member.List)
		}
	}

	//待出场车辆
	waitAppearOrderRouter := api.Group("/wait_appear_order")
	{
		waitAppearOrderRouter.POST("/list", waitAppearOrder.List)
	}

	//超时待离场

	timeoutNotLeavingRouter := api.Group("/timeout_not_leaving")
	{
		timeoutNotLeavingRouter.POST("/list", timeoutNotLeaving.List)
	}
}
